package no.uib.kwikktaim.gui.actionlisteners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collections;

import javax.swing.JOptionPane;

import no.uib.kwikktaim.gui.FullScreenMode;
import no.uib.kwikktaim.gui.MainWindow;

public class ManipulateMenu implements ActionListener {
	MainWindow mw;
	public ManipulateMenu(MainWindow mw) {
		this.mw = mw;
	}

	public void actionPerformed(ActionEvent e) {
		if(e.getSource().equals(mw.getJMenuBar().getMenu(0).getItem(0)))
			System.exit(0);
		else if (e.getSource().equals(mw.getJMenuBar().getMenu(1).getItem(1))) { // Media information
			JOptionPane.showMessageDialog(mw,mw.getPlayer().toString(),"Media Information",JOptionPane.INFORMATION_MESSAGE);
		}
		else if (e.getSource().equals(mw.getJMenuBar().getMenu(1).getItem(0))) { // Full screen
			if(mw.getPlayer().isVideo()) {
				FullScreenMode fsm = new FullScreenMode(mw.getPlayer(),mw);
			}
			else
				JOptionPane.showMessageDialog(mw, "This is not a video, so fullscreen is not supported", "Not a video ERROR! SOS! 404!", JOptionPane.INFORMATION_MESSAGE);
		}

		else if (e.getSource().equals(mw.getJMenuBar().getMenu(2).getItem(0))) { //Remove item
			mw.removeMediaFromPlayList();
		}

		else if (e.getSource().equals(mw.getJMenuBar().getMenu(1).getItem(3))) { //Increase speed
			mw.getPlayer().setSpeed((float) (mw.getPlayer().getSpeed()+0.1));
		}
		else if (e.getSource().equals(mw.getJMenuBar().getMenu(1).getItem(4))) { //Default speed
			mw.getPlayer().setSpeed(1);
		}
		else if (e.getSource().equals(mw.getJMenuBar().getMenu(1).getItem(5))) { //Decrease speed
			mw.getPlayer().setSpeed((float) (mw.getPlayer().getSpeed()-0.1));
		}

		else if (e.getSource().equals(mw.getJMenuBar().getMenu(2).getItem(1))) { //Add item
			mw.buttonAdd.doClick();
		}

		else if (e.getSource().equals(mw.getJMenuBar().getMenu(2).getItem(2))) { //Clear playlist
			mw.model.removeAllElements();
		}
//TODO - Legge til sorteringsfunksjonalitet
//		else if (e.getSource().equals(mw.getJMenuBar().getMenu(2).getItem(3))) { // Sort playlist..
//
//		}
		else if (e.getSource().equals(mw.getJMenuBar().getMenu(3).getItem(0))) { // About
			JOptionPane.showMessageDialog(mw,
					"Laget av Peder 'the man', Tobias 'the dude' og (snart?) Ole Henning 'the boy'.",
					"Kwikktaim v1.0",JOptionPane.INFORMATION_MESSAGE);
		}



	}

}
